<?

class MPalinsesto_vidwiz extends Model_vidwiz
{
    public function __construct( ) {
        global $config;
        $this->tableName = $config['tables']['palinsesto'];
        $this->installationFields = array(
                  array(
                      0 => 'id',
                      1 => 'int',
                      2 => 'NOT NULL AUTO_INCREMENT PRIMARY KEY'
                  ),
                  array(
                      0 => 'author',
                      1 => 'TEXT',
                      2 => 'NOT NULL'
                  ),
                  array(
                      0 => 'onairDate',
                      1 => 'date',
                      2 => 'NOT NULL'
                  ),
                  array(
                      0 => 'videoList',
                      1 => 'TEXT',
                      2 => 'NOT NULL'
                  ),
                  array(
                      0 => "title",
                      1 => "TEXT",
                      2 => "NOT NULL"
                  )
                );
    }


    /**
     * Ritorna l'ultimo palinsesto inserito sottoforma di array associativo $array[0][...]
     * @global array $config
     * @return array 
     */
    public function getLastPalinsesto(){
        global $config;
        $debug = USingleton_vidwiz::getInstances("UDebug_vidwiz");
        $date = "".date("Y-m-d");
        $query = $this->searchQuery($config['tables']['palinsesto'], array(array('onairDate','<=',"$date")), array("*"), "1","onairDate DESC,id DESC");
        return $this->getRowsAssoc($query);
    }

} // end of MPalinsesto
?>
